<%--
  Created by IntelliJ IDEA.
  User: Yancyxiaoone
  Date: 2022/12/6
  Time: 9:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>插入汽车信息</title>
</head>
<script src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //用户名文本框绑定失去焦点事件
        $("#id").blur(function () {
            if ($("#id").val() != "") {
                $.ajax({
                    url: "querycar",//设置服务器地址
                    type: "post",//提交方式
                    data: {id: $(this).val()},//提交到服务器的数据，多个值以逗号分割
                    success: function (data) { //回调函数，data是返回的数据
                        // alert("data: " + data);
                        $("#span").html(data);
                    }
                });
            } else {
                $("#span").html("");
            }
        });
    });
</script>
<script>
    function fun() {
        window.location.href = 'success.jsp';
    }
</script>
<style>
    table {
        position: relative;
    }

    td {
        white-space: nowrap;
    }

    #span {
        position: absolute;
    }
    a {
        text-decoration: none;
        color: blue;
    }
</style>
<body style="text-align: center">
<h1>插入信息</h1>
<form action="addcar" method="post">
    <table style="margin: auto">
        <tr>
            <td>汽车ID</td>
            <td><input id="id" type="text" name="id" value=""><span id="span"></span></td>
        </tr>
        <tr>
            <td>汽车Name</td>
            <td><input type="text" name="name" value=""></td>
        </tr>
        <tr>
            <td>汽车Type</td>
            <td><input type="text" name="type" value=""></td>
        </tr>
        <tr>
            <td>汽车Price</td>
            <td><input type="text" name="price" value=""></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="返回" onclick="fun()">
                <input type="submit" value="添加信息">
            </td>
        </tr>
    </table>
</form>
</body>
</html>
